#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
int n, x;
map<string, int>mp;
struct S
{
	string str;
	int time;
	int id;
}s[110];
int cmp(S a, S b)
{
	return a.time < b.time;
}
int ans[110];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i].str;
		cin >> s[i].time;
		s[i].id = i;
	}
	sort(s + 1, s + n + 1, cmp);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		mp[s[i].str] = s[i].time;
	}
	for (int i = 1; i <= n; i++) {
		if (mp[s[i].str] == s[i].time) {
			ans[++cnt] = s[i].id;
		}
	}
	for (int i = 1; i <= cnt; i++) {
		cout<<ans[i]<<endl;
	}
    return 0;
}
